<? 
	$title="Subscribe With Us";
	$pageid="3";
	$accessid="a00";
	require("required/dbconnect.php");
	require("required/share_function.php");
	require("required/header.php");	
	require("required/function.php");
	
	
	if(isset($_POST['btnsubmit']))
	{
		$sub_first_name=$_POST['sub_first_name'];
		$sub_last_name=$_POST['sub_last_name'];
		$sub_email=$_POST['sub_email'];
		$ip=$_SERVER['REMOTE_ADDR'];
		require_once('required/recaptchalib.php');
		
		$resp = recaptcha_check_answer ($captcha_key_private,
										$_SERVER["REMOTE_ADDR"],
										$_POST["recaptcha_challenge_field"],
										$_POST["recaptcha_response_field"]);
?>
	<table width="100%" cellpadding="6" cellspacing="0">
		<tr>
        	<td class="page_title_bar">
            Subscribe To Us
            </td>
        </tr>
        <tr>
			<td valign="top" height="400" align="center">
           		 <table width="300" >
                 	<td align="center"> 
<?	
		if (!$resp->is_valid) 
		{
?>
		
                 		<br /><br />
							<div class="dw_failed" width='200'>Invalid Security Code, please try again. </div>
                
               	 		<br /><br />
                		<input type="button" onclick="history.go(-1)" value="Back" class="button" />
					
<?					
		  }
		  else
		  {
			$chk=mysql_query("select count(*) as result from os_email_subscriber where sub_email='$sub_email'");
			
			if(mysql_result($chk,0,"result")>0)
			{
?>
 
                 		<br /><br />
							<div class="dw_failed">Email already exist, please try again. </div>
                
               	 		<br /><br />
                		<input type="button" onclick="history.go(-1)" value="Back" class="button" />
<?					
			}
			else
			{
				$regisdate=date('Y-m-d');
				$insert=mysql_query("insert into os_email_subscriber (sub_first_name,sub_last_name,sub_email,created_datetime,sub_ip,status)
									 values('$sub_first_name','$sub_last_name','$sub_email',now(),'$ip',1)")or die(mysql_error());
?>
                 		<br /><br />
						<div class="dw_success">Email subscribed, thank you! </div>
                    	<br /><br />
  
<?					
			}
		  }
?>
					</td>
                 </table>
			</td>
		</tr> 
</table>

<?  
	 
	require("required/footer.php");
			
		 
	} 
?>
